<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 1.引入vue.js文件 -->
    <script src="js/vue.js"></script>
</head>

<body>
    <!-- 声明式渲染 -->
    <div id="app">
        <p>{{num}}</p>
        <p>{{fun1}}</p>
        <p>{{fun2()}}</p>
        <button @click="fun1">获取num数据-fun1</button>
        <button @click="fun2()">获取num数据-fun2()</button>
        <!-- 传递参数 -->
        <button @click="fun3(2,3)">获取num数据-fun3(2,3)</button>
        <!-- 事件对象参数 -->
        <button @click="fun4">获取num数据-fun4</button>
        <button @click="fun5(3,5,$event)">获取num数据-fun5(num1,num2)</button>
    </div>
    <!-- {{msg}} -->
    <script>
        var app = new Vue({
            // element
            // 挂载元素
            el: '#app',
            // 渲染数据定义
            data: {
                num: 10
            },
            methods: {
                fun1: function() {
                    console.log(this);
                    console.log(this.num);
                    return this.num
                },
                fun2: function() {
                    console.log(this);
                    console.log(this.num);
                    return this.num
                },
                fun3: function(num1, num2) {
                    console.log(num1 + num2);
                    // 事件对象
                    console.log(event);
                    console.log(event.type);
                    console.log(event.target);
                },
                fun4: function(e) {
                    console.log(e);
                    console.log(e.type);
                },
                fun5: function(num1, num2, e) {
                    console.log(num1 + num2);
                    console.log(e);
                },
            }
        });
    </script>
</body>

</html>